﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caliburn.Micro;
using Agnes.Core;
using System.Collections.ObjectModel;
using Agnes.Libaray;

namespace Agnes.MyDocsLib
{
    /// <summary>
    /// DocsLib 概览树的ViewModel
    /// </summary>
    public class DocsLibSmartTreeViewModel
        : ScreenBase<ArticleManager>
    {
        private ObservableCollection<Catalog> _docsTree;
        public ObservableCollection<Catalog> DocsTree
        {
            get
            {
                return _docsTree;
            }
            set
            {
                _docsTree = value;
                NotifyOfPropertyChange(() => DocsTree);
            }
        }

        public DocsLibSmartTreeViewModel()
        {
            Model = ArticleManager.Instance;
            if (AgnesServiceManager.AgnesSlnService.CurrentSln != null)
            {
                ReLoadDate();
            }
        }

        public void ReLoadDate()
        {
            AgnesServiceManager.LogServ.Debug("MyDocsLib--加载知识库数据");
            DocsTree = ArticleManager.Instance.Roots;
        }

        protected override object CreateView()
        {
            return new DocsLibSmartTreeView();
        }
    }
}
